{extend name="adminblue/base" /}
{block name="resources"/}
<style type="text/css">
.set-style {
	width: 100%;
}

.set-style dl {
	width: 100%;
	font-size: 0;
	/* line-height: 20px; */
	clear: both;
	padding: 0;
	margin: 0;
	border-bottom: dotted 1px #E6E6E6;
	overflow: hidden;
}

.set-style dl dt {
	font-size: 12px;
	line-height: 32px;
	vertical-align: top;
	letter-spacing: normal;
	word-spacing: normal;
	text-align: right;
	display: inline-block;
	width: 19%;
	padding: 10px 1% 10px 0;
	margin: 0;
	font-weight: normal;
}

.set-style dl dd {
	font-size: 12px;
	line-height: 32px;
	vertical-align: top;
	letter-spacing: normal;
	word-spacing: normal;
	display: inline-block;
	width: 78%;
	padding: 10px 0 10px 0;
}

.set-style dl dd input[type="text"], .set-style dl dd input[type="password"]
	{
	font: 12px/20px Arial;
	color: #777;
	background-color: #FFF;
	vertical-align: top;
	display: inline-block;
	height: 24px;
	line-height: 24px;
	padding: 4px;
	border: 1px solid #CCC;
	outline: 0 none;
	width: 400px;
	margin: 0;
}

.set-style dl dd textarea {
	font: 12px/20px Arial;
	color: #777;
	background-color: #FFF;
	vertical-align: top;
	display: inline-block;
	height: 60px;
	padding: 4px;
	border: solid 1px #CCC;
	outline: 0 none;
	width: 400px;
	margin: 0;
}

.hint {
	font-size: 12px;
	line-height: 16px;
	color: #BBB;
	margin-top: 10px;
}

.set-style dl dd p img {
	border: medium none;
	vertical-align: middle;
}

.class-logo {
	background-color: #FFF;
	position: relative;
	z-index: 1;
}

.class-logo p {
	width: 200px;
	height: 60px;
	line-height: 0;
	background-color: #FFF;
	text-align: center;
	vertical-align: middle;
	display: table-cell;
	*display: block;
	overflow: hidden;
	margin: 0 0 10px;
	border: dashed 1px #E6E6E6;
}

.class-logo p img {
	max-width: 200px;
	max-height: 60px;
	border: medium none;
	vertical-align: middle;
	margin-top: expression(60-this .height/ 2);
	*margin-top: expression(30-this .height/ 2);
}

.edit_button {
	padding-top: 10px;
	padding-bottom: 10px;
	padding-left: 30px;
	padding-right: 30px;
	background-color: #51A351;
	color: #FFF;
	margin: 20px auto;
	border: none;
	display: block;
}

.error {
	font-size: 12px;
	line-height: 16px;
	color: red;
	margin-top: 10px;
	display: none;
}

.set-style dl dd p {
	margin-bottom: 0;
}
</style>
{/block}
{block name="main"}
<div class="set-style">
	<dl>
		<dt>账号类型:</dt>
		<dd>
			<p>
				<select class="form-control input-sm" id="bank_type">
					<option value="1">银行卡</option>
					<option value="2">支付宝</option> 
				</select>
			</p>
			<p class="error">请选择账号类型</p>
		</dd>
	</dl>
	<dl>
		<dt>支行信息:</dt>
		<dd>
			<p><input id="branch_bank_name" type="text"></p>
			<p class="error">请输入支行信息</p>
		</dd>
	</dl>
	<dl>
		<dt>真实姓名:</dt>
		<dd>
			<p><input id="realname" type="text"></p>
			<p class="error">请输入真实姓名</p>
		</dd>
	</dl>
	<dl>
		<dt>银行账号:</dt>
		<dd>
			<p><input id="account_number" type="text"></p>
			<p class="error">请输入银行账号</p>
		</dd>
	</dl>
	<dl>
		<dt>电话:</dt>
		<dd>
			<p><input id="mobile" type="text"></p>
			<p class="error">请输入电话</p>
		</dd>
	</dl>
	<button class="edit_button" onclick="addAccount();">提交</button>
</div>
{include file="adminblue/openDialog" /}
<script>
	/**
	 *模块输入信息验证
	 */
	function verify(branch_bank_name, realname, account_number,mobile) {
		if (branch_bank_name == '') {
			$("#branch_bank_name").parent().next().show();
			return flase;
		} else {
			$(".error").hide();
		}
		if (realname == '') {
			$("#realname").parent().next().show();
			return flase;
		} else {
			$(".error").hide();
		}
		if (account_number == '') {
			$("#account_number").parent().next().show();
			return flase;
		} else {
			$(".error").hide();
		}
		if (mobile == '') {
			$("#mobile").parent().next().show();
			return flase;
		} else {
			$(".error").hide();
		}
	}
	/**
	 *添加用户
	 **/
	function addAccount() {
		var bank_type = $("#bank_type").val();
		var branch_bank_name = $("#branch_bank_name").val();
		var realname = $("#realname").val();
		var account_number = $("#account_number").val();
		var mobile = $("#mobile").val();
		verify(branch_bank_name, realname, account_number,mobile);
		$.ajax({
			type : "post",
			url : "{:__URL('ADMIN_MAIN/account/addshopaccountbank')}",
			data : {
				'bank_type' : bank_type,
				'branch_bank_name' : branch_bank_name,
				'realname' : realname,
				'account_number' : account_number,
				'mobile' : mobile
			},
			async : true,
			success : function(data) {
				if (data['code'] > 0) {
				/* 	$("#dialog").dialog({
						buttons : {
							"确定" : function() {
								$(this).dialog('close');
							}
						},
						contentText : data["message"],
						time : 5,
						timeHref : "ADMIN_MAIN/account/shopbankaccountlist",
					}); */
					showMessage('success', data["message"]);
					location.href="{:__URL('ADMIN_MAIN/account/shopbankaccountlist')}";
				} else {
					$("#dialog").dialog({
						buttons : {
							"确定,#e57373" : function() {
								$(this).dialog('close');
							}
						},
						contentText : data["message"]
					});
				}
			}
		});
	}
</script>
{/block}